package com.recsmile.sgs.client.commonds;

import com.recsmile.sgs.client.entity.Hero;
import com.recsmile.sgs.client.entity.PlayerInfo;
import com.recsmile.sgs.client.operations.DiscardOperation;
import com.recsmile.sgs.client.ui.components.ClientGameUI;
import com.recsmile.sgs.client.ui.components.GamePanel;

public class DiscardGameUIClientCommand extends GeneralGameUIClientCommand {

	private static final long serialVersionUID = 2390690749143332929L;
	
	private final PlayerInfo currentPlayer;
	private final int amount;
	
	public DiscardGameUIClientCommand(PlayerInfo currentPlayer, int amount) {
		this.currentPlayer = currentPlayer;
		this.amount = amount;
	}
	
	@Override
	public void execute(GamePanel<? extends Hero> panel) {
		ClientGameUI<? extends Hero> panelUI = panel.getContent();
		if (panelUI.getSelf().getPlayerInfo().equals(currentPlayer)) {
			panel.pushOperation(new DiscardOperation(amount), null);
		} else {
			panelUI.getOtherPlayerUI(currentPlayer).showCountdownBar();
		}
	}

}